1
|
|
|
import {createButton, createButtonLink} from './cards'; |
2
|
|
|
import {chat_v1 as chatV1} from '@googleapis/chat/build/v1'; |
3
|
|
|
|
4
|
|
|
function getRandomString(string: Array<string>) { |
5
|
|
|
return string[Math.floor(Math.random() * string.length)]; |
6
|
|
|
} |
7
|
|
|
|
8
|
|
|
function getRandomFooter() { |
9
|
|
|
const footers = [ |
10
|
|
|
'We trust that you\'ll discover our service valuable, and we encourage you to reach out to us without hesitation should you have any inquiries or apprehensions.', |
11
|
|
|
'We hope you find our service useful and please don\'t hesitate to contact us if you have any questions or concerns.', |
12
|
|
|
'We trust that our service proves valuable to you. Should you have any inquiries or apprehensions, please feel free to reach out to us without hesitation.', |
13
|
|
|
'We anticipate that you\'ll find our service valuable, and please don\'t hesitate to get in touch if you have any questions or concerns.', |
14
|
|
|
'We appreciate your usage of our application and please don\'t hesitate to contact us if you have any questions or concerns.', |
15
|
|
|
'Thank you for using our app. We hope you\'ll find it to be a valuable tool', |
16
|
|
|
]; |
17
|
|
|
return getRandomString(footers); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
function getRandomGreet() { |
21
|
|
|
const greets = [ |
22
|
|
|
'Hi there! ', |
23
|
|
|
'Greetings! ', |
24
|
|
|
'Hello, ', |
25
|
|
|
'Hi, ', |
26
|
|
|
'Yay! ', |
27
|
|
|
]; |
28
|
|
|
return getRandomString(greets); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
function getRandomDescription() { |
32
|
|
|
const descriptions = [ |
33
|
|
|
'I\'m here to assist you in creating polls that can improve teamwork and streamline the process of making decisions.', |
34
|
|
|
'I can help you create polls to enhance collaboration and efficiency in decision-making using Google Chat™.', |
35
|
|
|
'I can help you make polls for better teamwork using Google Chat™', |
36
|
|
|
'I\'m capable of assisting you in generating polls that can boost collaboration and streamline decision-making through Google Chat™.', |
37
|
|
|
'My purpose is to support you in crafting polls that enhance teamwork and simplify the decision-making process.', |
38
|
|
|
'', |
39
|
|
|
]; |
40
|
|
|
return getRandomString(descriptions); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
function getRandomExample() { |
44
|
|
|
const examples = [ |
45
|
|
|
'"Which is the best country to visit" "Indonesia" "Bali"', |
46
|
|
|
'"When should we schedule our team days?" "Monday" "Tuesday" "Wednesday"', |
47
|
|
|
'"What would be the ideal date for our vacation?" "30 th February" "26 th March" "15 th April"', |
48
|
|
|
'"Which date works best for [event]?" "30 th February" "26 th March" "15 th April"', |
49
|
|
|
'"Your Question" "Answer 1" "Answer 2"', |
50
|
|
|
]; |
51
|
|
|
return getRandomString(examples); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
function getRandomInfo() { |
55
|
|
|
const info = [ |
56
|
|
|
'This app is designed to be used within group or space rooms with multiple members. However, if you\'d like to learn more about it, you can test it in a direct message (DM) conversation here.', |
57
|
|
|
'This app is a collaborative tool and is intended to be used in group or space rooms with multiple members. However, you can also test it out in a direct message (DM) here to discover more about its features.', |
58
|
|
|
'As a collaborative application, this is intended for use in group or space rooms with multiple members. However, you can also explore and test it further in a direct message (DM) here to gain a better understanding.', |
59
|
|
|
'This app is meant for group/space collaboration, but you can also test it via DM for more insights', |
60
|
|
|
'This is a collaborative app designed for group or space rooms, but you can also test it via DM for a better grasp.', |
61
|
|
|
'To enhance its functionality, install this app in a group or space room with multiple members. However, you can also test it in a direct message (DM) here to learn more.', |
62
|
|
|
]; |
63
|
|
|
return getRandomString(info); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
export function generateHelpText(isPrivate: boolean = false) { |
67
|
|
|
const greet = getRandomGreet(); |
68
|
|
|
const description = getRandomDescription(); |
69
|
|
|
const footer = getRandomFooter(); |
70
|
|
|
const example = getRandomExample(); |
71
|
|
|
const example2 = getRandomExample(); |
72
|
|
|
let additionalMessage = ''; |
73
|
|
|
if (isPrivate) { |
74
|
|
|
additionalMessage = getRandomInfo() + '\n\n'; |
75
|
|
|
} |
76
|
|
|
return greet + description + '\n' + |
77
|
|
|
'\n' + additionalMessage + |
78
|
|
|
'Below is an example commands:\n' + |
79
|
|
|
'`/poll` - You will need to fill out the topic and answers in the form that will be displayed.\n' + |
80
|
|
|
'`/poll ' + example + '` - to create a poll with autofill \n' + |
81
|
|
|
'\n' + |
82
|
|
|
'Alternatively, you can create poll by mentioning me with question and answers. ' + |
83
|
|
|
'e.g *@Absolute Poll ' + example2 + '*\n\n' + |
84
|
|
|
footer; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
export function generateHelperWidget() { |
88
|
|
|
return { |
89
|
|
|
'widgets': [ |
90
|
|
|
{ |
91
|
|
|
'divider': {}, |
92
|
|
|
}, |
93
|
|
|
{ |
94
|
|
|
'divider': {}, |
95
|
|
|
}, |
96
|
|
|
{ |
97
|
|
|
'divider': {}, |
98
|
|
|
}, |
99
|
|
|
{ |
100
|
|
|
'divider': {}, |
101
|
|
|
}, |
102
|
|
|
{ |
103
|
|
|
'textParagraph': { |
104
|
|
|
'text': 'If you have any problems, questions, or feedback, ' + |
105
|
|
|
'please feel free to post them <a href="https://github.com/dyaskur/google-chat-poll/issues">here</a> ', |
106
|
|
|
}, |
107
|
|
|
}], |
108
|
|
|
}; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
export const helperButtonCard = { |
112
|
|
|
'cardId': 'helper-card', |
113
|
|
|
'card': { |
114
|
|
|
'sections': [ |
115
|
|
|
{ |
116
|
|
|
'widgets': [ |
117
|
|
|
{ |
118
|
|
|
'buttonList': { |
119
|
|
|
'buttons': [ |
120
|
|
|
createButton('Create Poll', 'show_form', 'OPEN_DIALOG'), |
121
|
|
|
createButtonLink('Contact Us', 'https://github.com/dyaskur/google-chat-poll/issues'), |
122
|
|
|
createButtonLink('Give Us a Star', 'https://github.com/dyaskur/google-chat-poll'), |
123
|
|
|
], |
124
|
|
|
}, |
125
|
|
|
}, |
126
|
|
|
], |
127
|
|
|
}, |
128
|
|
|
], |
129
|
|
|
}, |
130
|
|
|
}; |
131
|
|
|
|
132
|
|
|
export const welcomeButtonCard: chatV1.Schema$CardWithId = { |
133
|
|
|
'cardId': 'welcome-card', |
134
|
|
|
'card': { |
135
|
|
|
'sections': [ |
136
|
|
|
{ |
137
|
|
|
'widgets': [ |
138
|
|
|
{ |
139
|
|
|
'buttonList': { |
140
|
|
|
'buttons': [ |
141
|
|
|
createButton('Create Poll', 'show_form', 'OPEN_DIALOG'), |
142
|
|
|
createButtonLink('Terms and Conditions', 'https://absolute-poll.yaskur.com/terms-and-condition'), |
143
|
|
|
createButtonLink('Contact Us', 'https://github.com/dyaskur/google-chat-poll/issues'), |
144
|
|
|
], |
145
|
|
|
}, |
146
|
|
|
}, |
147
|
|
|
], |
148
|
|
|
}, |
149
|
|
|
], |
150
|
|
|
}, |
151
|
|
|
}; |
152
|
|
|
|
153
|
|
|
|